package com.kalle.workflow.query;

import com.kalle.workflow.elements.Task;
import com.kalle.workflow.enums.TaskType;
import com.kalle.workflow.mapper.TaskMapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TaskQuery extends AbstractQuery<Task> {

    private final TaskMapper taskMapper;

    private final Map<String, Object> conditionMap;

    public TaskQuery(TaskMapper taskMapper) {
        this.taskMapper = taskMapper;
        this.conditionMap = new HashMap<>();
    }

    public TaskQuery deploymentId(String deploymentId) {
        conditionMap.put("deploymentId", deploymentId);
        return this;
    }

    public TaskQuery processKey(String processKey) {
        conditionMap.put("processKey", processKey);
        return this;
    }

    public TaskQuery name(String name) {
        conditionMap.put("name", name);
        return this;
    }

    public TaskQuery label(String label) {
        conditionMap.put("label", label);
        return this;
    }

    public TaskQuery taskType(TaskType taskType) {
        conditionMap.put("taskType", taskType.name());
        return this;
    }

    @Override
    public List<Task> list() {
        return taskMapper.list(conditionMap);
    }

}
